﻿using System;
using System.Collections.Generic;
using System.Text;
using OneMG.Phoenix.Service.Contracts;
using OneMG.Phoenix.Service.Model;
using OneMG.Phoenix.IBatisRepository;
using OneMG.Phoenix.Respository;
using System.Data;
using OneMG.Phoenix.Entity;

namespace OneMG.Phoenix.Service
{
    public class AdminGroupRightService : IAdminGroupRightService
    {
		 IAdminGroupRight adminGroupRight = new AdminGroupRightRepository();
		 
        public System.Int32 AddAdminGroupRight(AdminGroupRightModel model)
        {
			EAdminGroupRight entity = ConvertModelToEntity(model);
			
            return adminGroupRight.AddAdminGroupRight(entity);
        }

		public void UpdateByAdminGroupRightID (AdminGroupRightModel model)
		{
			EAdminGroupRight entity = ConvertModelToEntity(model);

            adminGroupRight.UpdateByAdminGroupRightID(entity);

		}

		public void DeleteByAdminGroupRightID (System.Int32 adminGroupRightID)
		{
		
            adminGroupRight.DeleteByAdminGroupRightID(adminGroupRightID);

		}
		 
        public AdminGroupRightModel GetByAdminGroupRightID (System.Int32 adminGroupRightID)
        {
        
			EAdminGroupRight entity = adminGroupRight.GetByAdminGroupRightID(adminGroupRightID);
			
            AdminGroupRightModel model = ConvertEntityToModel(entity);


            return model;
        }
        
		public AdminGroupRightModel ConvertEntityToModel(EAdminGroupRight entity)
		{
			if (entity == null)
            {
                return null;
            }
			AdminGroupRightModel model = new AdminGroupRightModel();
                        model.AdminGroupRightID = entity.AdminGroupRightID;
                        model.GroupID = entity.GroupID;
                        model.RightID = entity.RightID;
                        return model;
		}
		
		public EAdminGroupRight ConvertModelToEntity(AdminGroupRightModel model)
		{
			if (model == null)
            {
                return null;
            }
			EAdminGroupRight entity = new EAdminGroupRight();
                        entity.AdminGroupRightID = model.AdminGroupRightID;
                        entity.GroupID = model.GroupID;
                        entity.RightID = model.RightID;
                        return entity;
		}
    }
}